using NFreeMarker.Template;

namespace NFreeMarker.Core
{
    internal sealed class ParentheticalExpression : Expression
    {
        private readonly Expression _nested;

        internal ParentheticalExpression(Expression nested)
        {
            _nested = nested;
        }

        internal override bool IsTrue(Environment env)
        {
            return _nested.IsTrue(env);
        }

        public override string GetCanonicalForm()
        {
            return "(" + _nested.GetCanonicalForm() + ")";
        }

        protected override ITemplateModel _getAsTemplateModel(Environment env)
        {
            return _nested.GetAsTemplateModel(env);
        }

        internal override bool IsLiteral()
        {
            return _nested.IsLiteral();
        }

        protected override Expression DeepCloneImpl(string name, Expression subst)
        {
            return new ParentheticalExpression(_nested.DeepClone(name, subst));
        }
    }
}